import { getNetworkEmpPageSelect } from '@/api/network'
import { ref } from 'vue'
import { NetworkEmpOptional } from './types'

const useServicePersonalOptions = () => {
  const servicePersonalOptions = ref<Array<NetworkEmpOptional>>([])
  const getServicePersonalOptionsLoading = ref(false)

  const getServicePersonalOptions = async (keyword: string, networkId: string) => {
    getServicePersonalOptionsLoading.value = true
    const res = await getNetworkEmpPageSelect({ limit: 0, page: 0, name: keyword }, networkId)
    servicePersonalOptions.value = res.data.success ? res.data.data.rows : []
    getServicePersonalOptionsLoading.value = false
  }

  const clearServicePersonalOptions = () => {
    servicePersonalOptions.value = []
  }

  return {
    servicePersonalOptions,
    getServicePersonalOptionsLoading,
    getServicePersonalOptions,
    clearServicePersonalOptions,
  }
}

export default useServicePersonalOptions
